using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InduMall.Core.Models.Mapping
{
    public class InformationPageMap : EntityTypeConfiguration<InformationPage>
    {
        public InformationPageMap()
        {
            // Primary Key
            this.HasKey(t => t.InformationId);

            // Properties
            this.Property(t => t.InformationId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(32);

            this.Property(t => t.SeoWord)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.InforContent)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("InformationPage");
            this.Property(t => t.InformationId).HasColumnName("InformationId");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.SeoWord).HasColumnName("SeoWord");
            this.Property(t => t.InforContent).HasColumnName("InforContent");
            this.Property(t => t.CategoryId).HasColumnName("CategoryId");

            // Relationships
            this.HasRequired(t => t.Category)
                .WithMany(t => t.InformationPages)
                .HasForeignKey(d => d.CategoryId);

        }
    }
}
